package com.ns.dcjh.utils;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.muddzdev.styleabletoast.StyleableToast;
import com.ns.dcjh.R;

import org.apache.commons.lang3.StringUtils;

public final class ToastUtils {

    public ToastUtils() {

    }

    /**
     * Show Toast Msg
     * @param msg
     */
    public static void info(Context context, @Nullable String msg) {
        if (StringUtils.isEmpty(msg)) {
            msg = "未知消息";
        }

        new StyleableToast
                .Builder(context)
                .text(msg)
                .textColor(Color.WHITE)
                .backgroundColor(0xb3000000)
                .cornerRadius(0)
                .gravity(Gravity.CENTER)
                .length(Toast.LENGTH_SHORT)
                .show();
    }

    /**
     * Show Success Msg
     * @param msg
     */
    public static void success(Context context, @Nullable String msg) {
        if (msg == null) {
            msg = "未知消息";
        }

        new StyleableToast
                .Builder(context)
                .text(msg)
                .textColor(Color.WHITE)
                .backgroundColor(0xb3000000)
                .cornerRadius(0)
                .iconStart(R.drawable.ic_check_white_24)
                .gravity(Gravity.CENTER)
                .length(Toast.LENGTH_SHORT)
                .show();
    }
}
